﻿import com.crystalcentral.util.StringTool;

dynamic class com.crystalcentral.model.DiyImageItem extends com.crystalcentral.model.DiyItem
{
	private var _src:String;
	
	public function DiyImageItem() {
		if (arguments.length == 0)
		{
			super();
			this._type = "image";
		}
		else {
			var node:XMLNode = arguments[0];
			super(node);
			this.src = node.attributes.src;
		}
	}
	
	public function get src() {
		return this._src;
	}
	public function set src(val:String) {
		if (StringTool.beginsWith(val, "./"))
			val = val.substring(2, val.length);
		this._src = val;
	}
	
	public function toString():String {
		return "[DiyImageItem: "+this._src+"]";
	}
	
	public function clone() {
		var obj = new DiyImageItem();
		obj._x=this._x;
		obj._y=this._y;
		obj._width=this._width;
		obj._height=this._height;
		obj._xscale=this._xscale;
		obj._yscale=this._yscale;
		obj._rotation=this._rotation;
		obj._src=this._src;
		
		return obj;
	}
}